// @ts-ignore
/* eslint-disable */

import { request, type RequestOptions } from '@/utils/request';

/**
* workOrders
* @param params
* @returns
*/
export async function workOrders(params: any, options?: RequestOptions) {
    return request<any>(`workorder/workorders`, {
        method: 'POST',
        data: params,
        ...(options || {}),
    });
}

/**
* workOrders
* @param params
* @returns
*/
export async function myWorkOrders(params: any, options?: RequestOptions) {
    return request<any>(`workorder/myworkorders`, {
        method: 'POST',
        data: params,
        ...(options || {}),
    });
}

/**
* calendarlist日程
* @param params
* @returns
*/
export async function calendarlist(params: any, options?: RequestOptions) {
    return request<any>(`workorder/calendarlist`, {
        method: 'POST',
        data: params,
        ...(options || {}),
    });
}


/**
* all
* @param key:string
* @param customerId:string
* @param productId:string
* @returns
*/
export async function all(key: string, customerId?: string, productId?: string, options?: RequestOptions) {
    return request<any[]>(`workorder/all`, {
        method: 'GET',
        params: { key, customerId, productId },
        ...(options || {}),
    });
}

/**
* get
* @param id:string
* @returns
*/
export async function get(id: string, options?: RequestOptions) {
    return request<any>(`workorder/${id}`, {
        method: 'GET',
        ...(options || {}),
    });
}

/**
* edit
* @param data
* @returns
*/
export async function edit(data: any, options?: RequestOptions) {
    return request<any>(`workorder/edit`, {
        method: 'POST',
        data: data,
        ...(options || {}),
    });
}

/**
* create
* @param data
* @returns
*/
export async function create(data: any, options?: RequestOptions) {
    return request<any>(`workorder/create`, {
        method: 'POST',
        data: data,
        ...(options || {}),
    });
}

/**
* logicDelete
* @param id:string
* @returns
*/
export async function logicDelete(id: string, options?: RequestOptions) {
    return request<any>(`workorder/${id}/logic-delete`, {
        method: 'POST',
        ...(options || {}),
    });
}

/**
* realDelete
* @param id:string
* @returns
*/
export async function realDelete(id: string, options?: RequestOptions) {
    return request<any>(`workorder/${id}/real-delete`, {
        method: 'POST',
        ...(options || {}),
    });
}

/**
* updateStatus
* @param id:string
* @param status:number
* @returns
*/
export async function updateStatus(id: string, status: number, options?: RequestOptions) {
    return request<any>(`workorder/${id}/update-status`, {
        method: 'POST',
        data: JSON.stringify(status),
        headers: {
            'Content-Type': 'application/json',
            ...(options?.headers || {}),
        },
        ...(options || {}),
    });
} 

/**
* dispatch - 派单
* @param data 派单数据
* @returns
*/
export async function dispatch(data: any, options?: RequestOptions) {
    return request<any>(`workorder/dispatch`, {
        method: 'POST',
        data: data,
        ...(options || {}),
    });
} 

/**
* statistics - 获取工单统计信息
* @returns
*/
export async function statistics(options?: RequestOptions) {
    return request<any>(`workorder/statistics`, {
        method: 'GET',
        ...(options || {}),
    });
}

/**
* statistics - 获取我的工单统计信息
* @returns
*/
export async function mystatistics(options?: RequestOptions) {
    return request<any>(`workorder/mystatistics`, {
        method: 'GET',
        ...(options || {}),
    });
}

/**
* cancel - 取消工单
* @param id:string
* @param data 取消数据（包含取消原因）
* @returns
*/
export async function cancel(id: string, data: any, options?: RequestOptions) {
    return request<any>(`workorder/${id}/cancel`, {
        method: 'POST',
        data: data,
        ...(options || {}),
    });
}

/**
* userAvailability - 获取用户可用性状态
* @param params 查询参数（包含任务开始时间和结束时间）
* @returns
*/
export async function userAvailability(params: any, options?: RequestOptions) {
    return request<any>(`workorder/user-availability`, {
        method: 'POST',
        data: params,
        ...(options || {}),
    });
}